﻿using Castle.DynamicProxy;

namespace Selenium.PageToolkit
{
    public class CacheInterceptor : IInterceptor
    {
        private object _cache;

        public void Intercept(IInvocation invocation)
        {
            if (_cache != null)
            {
                invocation.ReturnValue = _cache;
                return;
            }
            invocation.Proceed();
            _cache = invocation.ReturnValue;
        }
    }
}